package io.github.ali.commons.enums;

/**
 * 二元状态
 * 
 * @author fuli
 * @date 2018年6月7日
 */
public enum YesNoStatus {
	/** Positive : 1/SUCCESS/是 */
	YES(1, "1", "SUCCESS", "是"), 
	/** Negative : 0/FAILED/否 */
	NO(0, "0", "FAILED", "否");

	/** 1/0 */
	public final Integer CODE;
	/** 1/0 */
	public final String NAME;
	/** SUCCESS/FAILED */
	public final String STATUS;
	/** 是/否 */
	public final String DESC;

	private YesNoStatus(Integer CODE, String NAME, String STATUS, String DESC) {
		this.CODE = CODE;
		this.NAME = NAME;
		this.STATUS = STATUS;
		this.DESC = DESC;
	}
	public static YesNoStatus valueOfCode(Integer CODE){
		for(YesNoStatus yns:values()){
			if (yns.CODE.equals(CODE)) {
				return yns;
			}
		}
		return null;
	}
	public static YesNoStatus valueOfName(String NAME){
		for(YesNoStatus yns:values()){
			if (yns.NAME.equals(NAME)) {
				return yns;
			}
		}
		return null;
	}
	public static YesNoStatus valueOfStatus(String STATUS){
		for(YesNoStatus yns:values()){
			if (yns.STATUS.equals(STATUS)) {
				return yns;
			}
		}
		return null;
	}
	public static YesNoStatus valueOfDesc(String DESC){
		for(YesNoStatus yns:values()){
			if (yns.DESC.equals(DESC)) {
				return yns;
			}
		}
		return null;
	}
}
